package org.coderfun.common.log.controller.admin;



import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import klg.common.model.EasyUIPage;
import klg.common.model.JsonData;
import klg.query.jpa.expr.AExpr;

import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.coderfun.common.log.entity.LoginLog;
import org.coderfun.common.log.entity.LoginLog_;
import org.coderfun.common.log.service.LoginLogService;



/**
 *
 * 
 * Generated by fieldmeta at 2018-11-23T22:34:30+08:00
 *
 */

@Controller("adminLoginLogController")
@RequestMapping("/admin/action/loginlog")
public class LoginLogController {
	@Autowired
	LoginLogService loginLogService;
	
	
	@ResponseBody
	@RequestMapping("/findpage")
	@RequiresPermissions("common:loginlog:query")
	public EasyUIPage findpage(
			@ModelAttribute LoginLog loginLog,
			@RequestParam int page,
			@RequestParam int rows){
		Pageable pageable=new PageRequest(page<1?0:page-1, rows, new Sort(Direction.DESC,"id"));
		Page<LoginLog> pageData=loginLogService.findPage(pageable,
				AExpr.contain(LoginLog_.opusername, loginLog.getOpusername()).igEmpty(),
				AExpr.eq(LoginLog_.successed, loginLog.getSuccessed()).igEmpty());
		return new EasyUIPage(pageData);
	}
		
}
